package cn.louguanyang.azure.biz.impl;

import android.content.Context;
import android.content.pm.PackageManager;
import android.os.Handler;

import cn.louguanyang.azure.biz.IUploadImageBiz;
import cn.louguanyang.azure.AzureConstants;
import cn.louguanyang.carbon.tasks.ImageUploadTask;
import cn.louguanyang.carbon.utils.ImageUtils;
import cn.louguanyang.carbon.utils.StringUtils;

/**
 * Created by louguanyang on 16/1/13.
 */
public class UploadImageBizImpl implements IUploadImageBiz{
    @Override
    public boolean cheackCamera(Context context) {
        return context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA);
    }

    @Override
    public void createFileBasePath() {
        ImageUtils.createFileBasePath();
    }

    @Override
    public void compressedAndUploadImage(Context context, String sourcePath, Handler handler) {
        if(StringUtils.isEmpty(sourcePath)) {
            return;
        }
        String targetPath = ImageUtils.cpmpressAndNewImage(sourcePath);
        if(StringUtils.isEmpty(sourcePath)) {
            return;
        }
        new ImageUploadTask(context, handler).execute(AzureConstants.UPLOAD_IMAGE_URL, targetPath, "123", "123");
    }
}
